package longrise.phone.com.itssnew.adapter;

import android.graphics.Color;
import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import longrise.phone.com.itssnew.R;
import longrise.phone.com.itssnew.bean.CompanyBean;


public class CompanyAdapter extends BaseQuickAdapter<CompanyBean, BaseViewHolder> {


    public CompanyAdapter(@LayoutRes int layoutResId, @Nullable List data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, CompanyBean item) {
        int number = item.getNum();
        if (number % 2 == 0) helper.setBackgroundRes(R.id.ll_company,R.drawable.view_double_selector);
        else helper.setBackgroundRes(R.id.ll_company,R.drawable.view_selector);
        helper.setText(R.id.company_item_position,String.valueOf(number + 1)) ;
        helper.setText(R.id.company_item_name,item.getName()) ;
        helper.setText(R.id.company_item_code,item.getCode()) ;
        helper.setText(R.id.company_item_value,item.getIsfillopinion()) ;
        String sum = item.getSum();
        if(sum != null){
            item.setAllrateb(true);
        }
        if (item.isAllrateb()) {
            helper.setText(R.id.company_item_score,sum == null || "".equals(sum) ? "未打分" : sum) ;
            helper.setTextColor(R.id.company_item_score,Color.BLACK);
        } else {
            helper.setText(R.id.company_item_score,"未完成打分") ;
            helper.setTextColor(R.id.company_item_score,Color.RED);
        }
    }
}
